/*
 * Created by zhangzxiang91@gmail.com on 2021/09/23.
 */
package com.perfma.util.model;

/**
 * @author zhangzxiang91@gmail.com
 * @date 2021/09/23.
 */
public class StorageProperties {
    public static final String MINIO_TYPE = "minio";
    /**
     * Minio存储配置
     */
    private MinioConfig minio;

    /**
     * 存储的类型
     */
    private String type = MINIO_TYPE;

    /**
     * 线程池核心线程数
     */
    private int coreThreads = Math.max(8, Runtime.getRuntime().availableProcessors() * 2);

    /**
     * 线程池最大线程数
     */
    private int maxThreads = Math.max(8, Runtime.getRuntime().availableProcessors() * 2);

    /**
     * 线程池最大队列等待数
     */
    private int maxQuequeCapacity = 2000;

    public String getType() {
        return type;
    }

    public int getCoreThreads() {
        return coreThreads;
    }

    public void setCoreThreads(int coreThreads) {
        this.coreThreads = coreThreads;
        if (maxQuequeCapacity < 1) {
            throw new RuntimeException("线程池核心线程数不能小于1");
        }
    }

    public int getMaxThreads() {
        return maxThreads;
    }

    public void setMaxThreads(int maxThreads) {
        this.maxThreads = maxThreads;
        if (maxQuequeCapacity < 1) {
            throw new RuntimeException("线程池最大线程数不能小于1");
        }
    }

    public int getMaxQuequeCapacity() {
        return maxQuequeCapacity;
    }

    public void setMaxQuequeCapacity(int maxQuequeCapacity) {
        this.maxQuequeCapacity = maxQuequeCapacity;
        if (maxQuequeCapacity < 1) {
            throw new RuntimeException("线程池最大队列等待数不能小于1");
        }
    }

    public MinioConfig getMinio() {
        return minio;
    }

    public void setMinio(MinioConfig minio) {
        this.minio = minio;
    }

    public static class MinioConfig {

        private String endpoint;
        private String externalEndpoint;
        private String accessKey;
        private String secretKey;
        private String bucketName = "default";
        private boolean bucketAutoCreate = true;
        // 文件分片上传，单个分片大小(5M)
        private long partSize = 5L * 1024 * 1024;

        public String getEndpoint() {
            return endpoint;
        }

        public void setEndpoint(String endpoint) {
            this.endpoint = endpoint;
        }

        public String getExternalEndpoint() {
            return externalEndpoint;
        }

        public void setExternalEndpoint(String externalEndpoint) {
            this.externalEndpoint = externalEndpoint;
        }

        public String getAccessKey() {
            return accessKey;
        }

        public void setAccessKey(String accessKey) {
            this.accessKey = accessKey;
        }

        public String getSecretKey() {
            return secretKey;
        }

        public void setSecretKey(String secretKey) {
            this.secretKey = secretKey;
        }

        public String getBucketName() {
            return bucketName;
        }

        public void setBucketName(String bucketName) {
            this.bucketName = bucketName;
        }

        public boolean isBucketAutoCreate() {
            return bucketAutoCreate;
        }

        public void setBucketAutoCreate(boolean bucketAutoCreate) {
            this.bucketAutoCreate = bucketAutoCreate;
        }

        public long getPartSize() {
            return partSize;
        }

        public void setPartSize(long partSize) {
            this.partSize = partSize;
        }
    }
}
